#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:

    int findLongestChain(vector<vector<int>>& pairs) {
        int n = pairs.size();
        compare mycompare;
        sort(pairs.begin(), pairs.end());
        vector<int> dp(n, 1);
        int ret = 0;
        for (int i = 0;i < n;i++)
        {
            for (int j = n - 1;j >= 0;j--)
            {
                if (pairs[i][0] > pairs[j][1]) dp[i] = max(dp[i], dp[j] + 1);
            }
            ret = max(ret, dp[i]);
        }
        for (int i = 0;i < n;i++)
        {
            cout << dp[i] << " ";
        }
        return ret;
    }
};